home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DllSys_Files / DELTABAR / DELTABAR.C
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.6 KB  |  52 lines

  1. // Dynamic link library implementation of NeuroSolutions DeltaBarDelta component 
  2.  
  3. #include "NSDLL.h" 
  4.  
  5. /*****************************/
  6. /* Gradient search procedure */
  7.  
  8. __declspec(dllexport) void performDeltaBarDelta(
  9.     DLLData    *instance,        // Pointer to instance data (may be NULL)
  10.     NSFloat *step,            // Pointer to vector of learning rates for each weight
  11.     int    length,                // Length of learning rate vector
  12.     NSFloat    momentum,        // Momentum rate for all weights
  13.     NSFloat    *delta,            // Last weight Update
  14.     NSFloat *gradient,        // Gradient vector from backprop component
  15.     NSFloat *smoothedGradient,    // Smoothed gradient vector
  16.     NSFloat beta,            // Multiplicative constant
  17.     NSFloat kappa,            // Additive constant
  18.     NSFloat zeta             // Smoothing factor
  19.     )
  20. {    
  21.     int i;
  22.  
  23.     for (i=0; i<length; i++) {
  24.         if (smoothedGradient[i]*gradient[i] > 0)
  25.             step[i] += kappa;
  26.         else
  27.             if (smoothedGradient[i]*gradient[i] < 0)
  28.                 step[i] -= beta*step[i];
  29.         smoothedGradient[i] = (1-zeta)*gradient[i] + zeta*smoothedGradient[i];
  30.     }
  31. }
  32.  
  33. /******************************************/
  34. /* Management of instance data (OPTIONAL) */
  35. /*
  36. __declspec(dllexport) DLLData *allocDeltaBarDelta(
  37.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  38.     int    length,        // Length of the weight vector
  39.     BOOL    individual    // Indicates whether their is one learning rate for all weights (FALSE),
  40.                 // or each weight has its own learning rate
  41.     )
  42. {
  43.     DLLData *instance = allocDLLInstance(oldInstance);
  44.     return instance;
  45. }
  46.  
  47. __declspec(dllexport) void freeDeltaBarDelta(DLLData *instance)
  48. {
  49.     freeDLLInstance(instance);
  50. }
  51. */
  52.